﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Infragistics.WebUI.UltraWebGrid;
using Infragistics.WebUI.WebCombo;

namespace Utility
{
    /// <summary>
    /// 表格以及各控件样式设置(自定义)
    /// </summary>
    public class InitUltraWebGrid
    {
        public InitUltraWebGrid()
        {

        }

        /// <summary>
        /// (UltraWebGrid)该样式适用于各统计页面的表格，只是浏览数据,没有其它作何操作
        /// </summary>
        /// <param name="u">传入一个UltraWebGrid的对象</param>
        public static void InitDisplayLayOut(UltraWebGrid u)
        {
            u.DisplayLayout.GroupByBox.Hidden = true;                                                   //隐藏表格最上面那行
            u.DisplayLayout.AutoGenerateColumns = false;                                                //禁止表格自动生成列
            u.DisplayLayout.Bands[0].CellClickAction = CellClickAction.RowSelect;                       //设置表格为行选择模式
            u.Bands[0].AllowUpdate = AllowUpdate.No;                                                    //表格不允许编辑

            u.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;                                     //显示列头指示游标
            u.DisplayLayout.RowSelectorStyleDefault.Width = 15;                                         //指示列头的宽度

            u.DisplayLayout.StationaryMargins = StationaryMargins.Header;                               //固定表头
            u.DisplayLayout.HeaderStyleDefault.HorizontalAlign = HorizontalAlign.Center;                //表头文字居中
            u.DisplayLayout.HeaderStyleDefault.BackgroundImage = "~/images/bg_index.jpg";               //表头背景

            u.DisplayLayout.RowStyleDefault.HorizontalAlign = HorizontalAlign.Center;                   //表格中内容居中       
            u.DisplayLayout.SelectedRowStyleDefault.BackColor = System.Drawing.Color.LightGreen;        //选中行的颜色
            u.BackColor = System.Drawing.Color.White;                                                   //表格背景颜色
            u.BorderColor = System.Drawing.ColorTranslator.FromHtml("#85BDE2"); ;                       //表格边框颜色
            u.BorderStyle = BorderStyle.Groove;                                                         //表格边框样式

            //u.DisplayLayout.Pager.AllowCustomPaging = true;                                             //允许自定义分页
            //u.DisplayLayout.Pager.AllowPaging = true;                                                   //显示分页栏
            u.DisplayLayout.Pager.Style.BackgroundImage = "~/images/bg_index.jpg";               //分页栏的背景图片
            //u.DisplayLayout.Pager.Style.BackColor = System.Drawing.Color.LightBlue;                     //分页栏的背景
                    


            /*       
             *  注意：各列的宽度手动设置，不能在这里统一
             */
        }

        /// <summary>
        /// (UltraWebGrid)该样式适用于订单明细表格，可操作表格中的数据
        /// </summary>
        /// <param name="u">传入一个UltraWebGrid的对象</param>
        public static void InitDisplayLayOut_Oper(UltraWebGrid u)
        {
            u.DisplayLayout.GroupByBox.Hidden = true;                                                   //隐藏表格最上面那行
            u.DisplayLayout.AutoGenerateColumns = false;                                                //禁止表格自动生成列
            //u.DisplayLayout.Bands[0].CellClickAction = CellClickAction.RowSelect;                       //设置表格为行选择模式
            u.Bands[0].AllowUpdate = AllowUpdate.Yes;                                                   //表格允许编辑

            u.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;                                     //显示列头指示游标
            u.DisplayLayout.RowSelectorStyleDefault.Width = 15;                                         //指示列头的宽度

            u.DisplayLayout.StationaryMargins = StationaryMargins.Header;                               //固定表头
            u.DisplayLayout.HeaderStyleDefault.HorizontalAlign = HorizontalAlign.Center;                //表头文字居中
            u.DisplayLayout.HeaderStyleDefault.BackgroundImage = "~/images/bg_index.jpg";        //表头背景

            u.DisplayLayout.RowStyleDefault.HorizontalAlign = HorizontalAlign.Center;                   //表格中内容居中       
            u.DisplayLayout.SelectedRowStyleDefault.BackColor = System.Drawing.Color.PaleGreen;         //选中行的颜色
            u.BackColor = System.Drawing.Color.White;                                                   //表格背景颜色
            u.BorderColor = System.Drawing.ColorTranslator.FromHtml("#85BDE2");                         //表格边框颜色
            u.BorderStyle = BorderStyle.Groove;                                                         //表格外围边框样式
            u.DisplayLayout.RowStyleDefault.BorderStyle = BorderStyle.Dotted;                           //表格内部边框样式 

            u.DisplayLayout.AllowDeleteDefault = AllowDelete.Yes;                                       //允许删除
        }

        /// <summary>
        /// (WebCombo)该样式适用于下拉表格
        /// </summary>
        public static void InitWebCombo(WebCombo w)
        {
            w.DropDownLayout.AutoGenerateColumns = false;                                               //不允许自动生成列
            w.DropDownLayout.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;                      //下拉表格表头内容居中显示
            w.DropDownLayout.HeaderStyle.BackgroundImage = "~/images/bg_index.jpg";              //表头背景                 
            
            w.DropDownLayout.SelectedRowStyle.BackColor = System.Drawing.Color.LightGreen;              //选中行后的颜色
            w.DropDownLayout.RowStyle.HorizontalAlign = HorizontalAlign.Center;                         //下拉表格数据居中显示
            w.DropDownLayout.RowStyle.BorderStyle = BorderStyle.Dotted;                                 //表格内部边框样式        

        }

    }
}